//
//  CZQLoginManager.m
//  LoveBeer
//
//  Created by 崔正强 on 17/4/27.
//  Copyright © 2017年 崔正强. All rights reserved.
//

#import "CZQLoginManager.h"

@implementation CZQLoginManager

+ (instancetype)sharedManager {
    
    static CZQLoginManager *_mgr;

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _mgr = [CZQLoginManager new];
    });
    return _mgr;
}

#pragma - 短信验证登录 -
- (void)logiWithPhone:(NSString *)phoneNum Verify:(NSString *)verify finished:(void(^)(SMSSDKUserInfo *userInfo, NSError *error))result{
    
    [SMSSDK commitVerificationCode:verify phoneNumber:phoneNum zone:@"86" result:^(SMSSDKUserInfo *userInfo,NSError *error) {
        if (error == nil) {
            self.isLogin = YES;
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:KisLogin];
            [[NSUserDefaults standardUserDefaults] setObject:phoneNum forKey:KPhoneNum];
            self.phoneNum = phoneNum;
        }
        result(userInfo,error);
    }];
    
}

- (void)getVerifyWithPhoneNum:(NSString *)phoneNum result:(void(^)(NSError *error))result{
    
    [SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:phoneNum zone:@"86" customIdentifier:nil result:result];
    
}

- (BOOL)isLogin{
    
    return [[[NSUserDefaults standardUserDefaults] valueForKey:KisLogin] boolValue];
}


@end
